package com.yang.newCustomersTransferBackProcess.controller;

import com.yang.newCustomersTransferBackProcess.pojo.Adviser;
import com.yang.newCustomersTransferBackProcess.pojo.ToExamineTransferBack;
import com.yang.newCustomersTransferBackProcess.service.ToExamineTransferBackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class NewCustomersTransferBackController {

    @Autowired
    private ToExamineTransferBackService toExamineTransferBackService;

    @PostMapping("/insertNewCustomersTransferBack")
    public Map<String, Object> insertNewCustomersTransferBack(@RequestParam(name = "customerId") int customerId,
                                                              @RequestParam(name = "customerName") String customerName,
                                                              @RequestParam(name = "adviserId") int adviserId,
                                                              @RequestParam(name = "adviserName") String adviserName){

       return toExamineTransferBackService.insertNewCustomersTransferBack(customerId, customerName, adviserId, adviserName);
    }

    @PostMapping("/toExamine")
    public Map<String, Object> toExamine(@RequestParam(name = "toExamineTransferBackId") int toExamineTransferBackId, @RequestParam(name = "adviserId") int adviserId){

        return toExamineTransferBackService.toExamine(toExamineTransferBackId, adviserId);
    }

    @PostMapping("/failedPassAudit")
    public Map<String, Object> failedPassAudit(@RequestParam(name = "toExamineTransferBackId") int toExamineTransferBackId, @RequestParam(name = "adviserId") int adviserId){

        return toExamineTransferBackService.failedPassAudit(toExamineTransferBackId, adviserId);
    }

    @PostMapping("/queryToExamineTransferBack")
    public List<ToExamineTransferBack> queryToExamineTransferBack(@RequestParam(name = "adviserId") int adviserId){

        return toExamineTransferBackService.queryToExamineTransferBack(adviserId);
    }

    @PostMapping("/checkLeader")
    public Adviser checkLeader(@RequestParam(name = "adviserId") int adviserId,
                               @RequestParam(name = "digit") int digit
                                                              ){

        return toExamineTransferBackService.checkLeader(adviserId, digit);
    }
}
